/**
 * 
 */
package co.com.smart.eagle.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author user
 */
@Entity
@Table(name = "users")
public class EagleSecurityUsers implements Serializable {
    @JoinTable(name = "users_roles", joinColumns = {
        @JoinColumn(name = "username", referencedColumnName = "username")}, inverseJoinColumns = {
        @JoinColumn(name = "rolename", referencedColumnName = "rolename")})
    @ManyToMany
    private List<EagleSecurityRoles> eagleSecurityRolesList;
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "username")
    private String username;
    @Column(name = "password")
    private String password;

    public EagleSecurityUsers() {
    }

    public EagleSecurityUsers(String username) {
        this.username = username;
    }

    public EagleSecurityUsers(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EagleSecurityUsers)) {
            return false;
        }
        EagleSecurityUsers other = (EagleSecurityUsers) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.com.smart.eagle.persistence.entity.security.EagleSecurityUsers[ username=" + username + " ]";
    }

    @XmlTransient
    public List<EagleSecurityRoles> getEagleSecurityRolesList() {
        return eagleSecurityRolesList;
    }

    public void setEagleSecurityRolesList(List<EagleSecurityRoles> eagleSecurityRolesList) {
        this.eagleSecurityRolesList = eagleSecurityRolesList;
    }
    
}

